package com.wj.rspmproperty.controller;


import com.wj.rspmproperty.pojo.Floor;
import com.wj.rspmproperty.pojo.ResponsePojo;
import com.wj.rspmproperty.service.FloorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author WeiJin
 * @version 1.0
 */
@Api(tags = "楼层相关接口")
@RestController
@RequestMapping("/floor")
public class FloorController {

    @Autowired
    private FloorService floorService;

    /**
     * 根据楼栋id查询楼层
     * @param buildingId
     * @return
     */
    @GetMapping("/floorOfBuilding/{buildingId}")
    @ApiOperation(value = "根据楼栋id查询楼层信息", responseContainer = "List")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "buildingId", type = "Integer", required = true)
    )
    public ResponsePojo<List<Floor>> floorOfBuilding(@PathVariable("buildingId") Integer buildingId) {
        List<Floor> list = floorService.floorOfBuilding(buildingId);
        if (list.size() > 0) {
            return ResponsePojo.success(list);
        } else {
            return ResponsePojo.fail(list, "id查询不到楼层信息");
        }

    }
}
